package com.tanhua.dubbo.api;

import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.itheima.model.pojo.UserLock;
import com.tanhua.dubbo.mapper.UserLockMapper;
import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.beans.factory.annotation.Autowired;

@DubboService
public class UserLockApiImpl implements UserLockApi{

    @Autowired
    private UserLockMapper userLockMapper;

    @Override
    public UserLock findByUserIdAndQuestionnaireId(Long userId, Long id) {
        return userLockMapper.selectOne(
                Wrappers.lambdaQuery(UserLock.class)
                        .eq(UserLock::getUserId, userId)
                        .eq(UserLock::getQuestionnaireId, id)
        );
    }

    @Override
    public void save(UserLock userLock) {
        userLockMapper.insert(userLock);
    }

    @Override
    public void update(UserLock userLock) {
        userLockMapper.updateById(userLock);
    }
}
